package com.zhonggong.nine;

public class Student extends Person{
	
	private String major="Computer science";
	
	public Student(Name name) {
		super(name);
	}

	public Student(Name name, String major) {
		super(name);
		this.major = major;
	}

	public String getMajor() {
		return major;
	}

	public void setMajor(String major) {
		this.major = major;
	}

	@Override
	public String toString() {
		return this.getName().getFullName()+
				"\nMajor: "+this.major;
	}

	@Override
	public int compareTo(Object o) {
		// TODO Auto-generated method stub
		int n;
		Student student = (Student)o;
		n = this.major.compareTo(student.major);
		if(n!=0)return n;
		return super.compareTo(student.getName());
	}
	
	
}
